package com.example.mobile2021606127cxz0507;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private EditText edtUsername;
    private EditText edtPsw;
    private Button btnLogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        edtUsername = (EditText) findViewById(R.id.edt_username);
        edtPsw = (EditText) findViewById(R.id.edt_psw);
        btnLogin = (Button) findViewById(R.id.btn_login);
    }

    public void login(View view) {
        Intent intent = new Intent(this, MainActivity2.class);


        //第一种方式
        intent.putExtra("username", edtUsername.getText().toString().trim());

        //第二种方式
        Bundle bundle = new Bundle();
        bundle.putString("psw", edtPsw.getText().toString().trim());
        intent.putExtras(bundle);

        startActivity(intent);

    }
}